package com.wuyan.locationdog.adapter

import android.widget.TextView
import androidx.annotation.LayoutRes
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.arcsoft.commonbase.bean.TeamDetail
import com.arcsoft.commonbase.ext.radius
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.wuyan.locationdog.R
import com.wuyan.locationdog.view.TeamGridView


class TeamListAdapter(@LayoutRes layoutResId: Int, data: MutableList<TeamDetail>?) :
    BaseQuickAdapter<TeamDetail, BaseViewHolder>(layoutResId, data) {


    override fun convert(holder: BaseViewHolder, item: TeamDetail) {
        holder.apply {
            getView<TeamGridView>(R.id.teamGridView).apply {
                radius(4F)
                setTeamNum(item.teamMembers!!)
            }

            getView<TextView>(R.id.teamName).text = item.teamName
            getView<TextView>(R.id.tvNum).text = item.teamMembers!!.size.toString() + "人"


            getView<RecyclerView>(R.id.recyclerView).apply {
                layoutManager = LinearLayoutManager(context, LinearLayoutManager.HORIZONTAL, false)
                val mAdapter = TeamPersonListAdapter(R.layout.item_team_img, null)
                adapter = mAdapter
                mAdapter.setNewInstance(item.teamMembers?.toMutableList())

                setOnTouchListener { v, event ->
                    // 在这里决定是否允许点击，例如返回false来禁止点击
                    holder.itemView.onTouchEvent(event);
                }
            }


        }
    }
}


